import base64
import requests
headers = {
        "User-Agent": "yuanrenxue.project",
        'Cookie': 'sessionid=84rfzmmclgdvknl834a394ole9kmxdmk'
    }
def get_data(page):
    zfc='yuanrenxue' + str(page)
    m=base64.b64encode(zfc.encode()).decode('utf-8')
    url='https://match.yuanrenxue.com/api/match/12'
    params={
        'page': page,
        'm': m
    }
    response=requests.get(url=url,params=params,headers=headers).json()
    # print(response)
    value_sum=get_sum(response)
    return value_sum
def get_sum(response):
    data=response.get('data')
    value_sum=0
    for da in data:
        value_sum+=da.get('value')
    return value_sum
def main():
    all_sum=0
    for page in range(1,5+1):
        value_sum=get_data(page)
        all_sum+=value_sum
        print(f'第{page}页和为:',value_sum)
    print(f'{page}页总和为',all_sum)
if __name__ == '__main__':
    main()
